package com.leen.video.controller;


import com.leen.admin.dto.DeptDto;
import com.leen.admin.entity.Dept;
import com.leen.common.vo.ResultEnum;
import com.leen.common.vo.ResultVO;
import com.leen.video.entity.LocalStorage;
import com.leen.video.repository.LocalStorageRepository;
import com.leen.video.service.LocalStorageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 本地存储接口
 * @author xjl
 * @date 2021-05-19
 */
@RestController
@Api(tags = "本地存储接口API")
@RequestMapping(value = "/video")
public class LocalStorageController {

    @Autowired
    private LocalStorageService localStorageService;


    @ApiOperation(value = "全查询")
    @GetMapping(value = "/localStorage/findAll")
    public ResultVO<ResultVO> findAll(){
        return ResultVO.success(this.localStorageService.findAll());
    }

    @ApiOperation(value = "新增数据")
    @PostMapping(value = "/localStorage/add")
    public ResultVO<String> add(@RequestBody LocalStorage localStorage){
        LocalStorage save =this.localStorageService.save(localStorage);
        return save!=null? ResultVO.success(ResultEnum.DB_SUCCESS):ResultVO.failed(ResultEnum.DB_FAILED);
    }

    @ApiOperation(value = "修改数据")
    @PostMapping(value = "/localStorage/updata")
    public ResultVO<String> updata(LocalStorage localStorage){
        LocalStorage updata = this.localStorageService.save(localStorage);
        return updata!=null? ResultVO.success(ResultEnum.DB_SUCCESS):ResultVO.failed(ResultEnum.DB_FAILED);
    }

}
